package com.ruoyi.web.controller.storeGroupPackage;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GroupPurchasePackageItem;
import com.ruoyi.system.service.IGroupPurchasePackageItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 团购套餐包含的商品Controller
 *
 * @author ruoyi
 * @date 2025-05-14
 */
@Api(tags="团购套餐包含的商品")
@RestController
@RequestMapping("/system/groupPurchasePackageItem")
public class GroupPurchasePackageItemController extends BaseController
{
    @Autowired
    private IGroupPurchasePackageItemService groupPurchasePackageItemService;

    /**
     * 查询团购套餐包含的商品列表
     */
    @ApiOperation("查询团购套餐包含的商品列表")
    @PreAuthorize("@ss.hasPermi('system:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(GroupPurchasePackageItem groupPurchasePackageItem)
    {
        startPage();
        List<GroupPurchasePackageItem> list = groupPurchasePackageItemService.selectGroupPurchasePackageItemList(groupPurchasePackageItem);
        return getDataTable(list);
    }

    /**
     * 导出团购套餐包含的商品列表
     */
    @ApiOperation("导出团购套餐包含的商品列表")
    @PreAuthorize("@ss.hasPermi('system:item:export')")
    @Log(title = "团购套餐包含的商品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GroupPurchasePackageItem groupPurchasePackageItem)
    {
        List<GroupPurchasePackageItem> list = groupPurchasePackageItemService.selectGroupPurchasePackageItemList(groupPurchasePackageItem);
        ExcelUtil<GroupPurchasePackageItem> util = new ExcelUtil<GroupPurchasePackageItem>(GroupPurchasePackageItem.class);
        util.exportExcel(response, list, "团购套餐包含的商品数据");
    }

    /**
     * 获取团购套餐包含的商品详细信息
     */
    @ApiOperation("获取团购套餐包含的商品详细信息")
    @PreAuthorize("@ss.hasPermi('system:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(groupPurchasePackageItemService.selectGroupPurchasePackageItemById(id));
    }

    /**
     * 新增团购套餐包含的商品列表
     */
    @ApiOperation("新增团购套餐包含的商品列表")
    @PreAuthorize("@ss.hasPermi('system:item:add')")
    @Log(title = "团购套餐包含的商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GroupPurchasePackageItem groupPurchasePackageItem)
    {
        return toAjax(groupPurchasePackageItemService.insertGroupPurchasePackageItem(groupPurchasePackageItem));
    }

    /**
     * 修改团购套餐包含的商品列表
     */
    @ApiOperation("修改团购套餐包含的商品列表")
    @PreAuthorize("@ss.hasPermi('system:item:edit')")
    @Log(title = "团购套餐包含的商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GroupPurchasePackageItem groupPurchasePackageItem)
    {
        return toAjax(groupPurchasePackageItemService.updateGroupPurchasePackageItem(groupPurchasePackageItem));
    }

    /**
     * 删除团购套餐包含的商品列表
     */
    @ApiOperation("删除团购套餐包含的商品列表")
    @PreAuthorize("@ss.hasPermi('system:item:remove')")
    @Log(title = "团购套餐包含的商品", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(groupPurchasePackageItemService.deleteGroupPurchasePackageItemByIds(ids));
    }
}
